import {Doc} from '../../../models/Doc';
import {Group} from '../../../models/Group';
import {Project} from '../../../models/Project';
export class DocsWithProjectDto{
  static toReturn(project:Project,groups:Group[],docs:Doc[]):any
  {
    var res =
    {
      projectId:project._id,
      title:project["title"],
      description:project["description"],
      groups:[]
    }

    for(var i=0;i<groups.length;i++)
    {
      var g = groups[i]
      var g_ = {
        _id:g._id,
        name:g.name,
        description:g.description,
        docs:[]
      };
      for(var m=0;m<docs.length;m++)
      {
        var doc:Doc = docs[m];
        if(doc.group["_id"]+""===g._id+"")
        {
          g_.docs.push(doc);
        }
      }
      res.groups.push(g_);
    }
    return res;
  }
}
